import jdk.swing.interop.SwingInterOpUtils;

import java.util.Arrays;

public class Text {
    public static void merge(int A[], int m, int B[], int n) {
        int fa = 0, fb = 0;
        while(fb < n){
            if(A[fa] >= B[fb]){
                for (int i = A.length - 2; i >=fa ; i--) {
                    A[i + 1] = A[i];
                }
                A[fa++] = B[fb++];
            }else {
                if(fa < m + n - 1) {
                    fa++;
                }//向前走一步
                if(A[fa] == 0){         //为0直接赋值
                    A[fa++] = B[fb++];
                }
                else if(A[fa] >= B[fb]){
                    for (int i = A.length - 2; i >=fa ; i--) {
                        A[i + 1] = A[i];
                    }
                    A[fa++] = B[fb++];
                }
            }
        }
    }
    public static void main(String[] args) {
        int[] a = new int[]{2,8,45,0,0,0};
        int[] b = new int[]{1,10,11};
        merge(a,3,b,3);
        System.out.println(Arrays.toString(a));
    }
}
